<?php
namespace  App\Admin\Extensions;
/**
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */
use Encore\Admin\Admin;

class RefundRow
{
    protected $id;
    public function __construct($id)
    {
        $this->id = $id;
    }

    protected function script()
    {
        return <<<SCRIPT

$('.grid-check-row').on('click', function () {
  swal({ 
  title: "确定要退票么？", 
  text: "退票后将清楚推广人的佣金", 
  type: "warning",
  showCancelButton: true, 
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "确定退票！", 
   confirButtonColor: "#DD6B55",
  confirButtonText: "确定退票！", 
  cancelButtonText: "取消！",
  closeOnConfirm: false, 
  closeOnCancel: false	
},
function(isConfirm){ 
  if (isConfirm) { 
  $.post('');
    swal("删除！", "你的虚拟文件已经被删除。",
"success"); 
  } else { 
    swal("取消！", "你的虚拟文件是安全的:)",
"error"); 
  } 
});


    // Your code.
    console.log($(this).data('id'));

});

SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());

        return "<a class='btn btn-xs btn-success fa fa-check grid-check-row' data-id='{$this->id}'></a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}

